﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace AssistantStartHelper
{
    public class Startup
    {
        protected static string appPath = @"E:\Mine\SuntabuAssistant\SuntabuAssistant\bin\Debug\SuntabuAssistant.exe";
        private static string test = @"D:\MyTools\p2psearcher3.5y\p2psearcher3.5\p2pseracher.exe";

        public static bool SearchInstance()
        {
            bool isFound = false;
            var pArry = Process.GetProcessesByName("SuntabuAssistant");
            if (pArry.Length != 0)
            {
                isFound = true;
            }

            return isFound;
        }

        public static bool StartupAssist()
        {
            try
            {
                if (!SearchInstance())
                {
                    ApplicationLoader.PROCESS_INFORMATION procInfo;
                    ApplicationLoader.StartProcessAndBypassUAC(appPath, out procInfo);
                }
                return true;
            }
            catch (Exception)
            {

                return false;
            }


        }
    }
}
